<template>
  <div>
    <lan-header :config="headerConfig"></lan-header>
    <lan-search-form
      size="small"
      :config="searchForm"
      :formData="searchFormData"
      @search="search"
    ></lan-search-form>
    <add
      ref="addComponent"
      @refresh="search"
    ></add>
  </div>
</template>

<script>
import lanSearchForm from '../../../components/lanSearchForm';
import lanHeader from '../../../components/lanHeader';
import { createAreaApi } from '../../../api/area';
import moment from 'moment';
import { MomentFormat, SortType } from '../../../constants/common';
import { Message, MessageBox } from 'element-ui';
import { deleteAreaApi, getAreaListApi } from '../../../api/area';
import { parseError } from '../../../utils';
import Add from './add';

export default {
  components: {
    lanHeader,
    lanSearchForm,
    Add
  },
  props: {
    searchFormData: {
      type: Object,
      default() {
        return {};
      }
    }
  },
  data() {
    return {
      headerConfig: {
        title: '报警规则',
        buttons: [
          {
            isShow: () => this.userGuardList.includes(this.guard.AlarmRuleManage),
            text: '新建',
            icon: 'add',
            type: 'primary',
            size: 'small',
            method: () => {
              this.showAdd();
            }
          }
        ]
      },

      searchForm: {
        inline: true,
        size: 'small',
        formList: [
          {
            name: 'name',
            type: 'input',
            placeholder: '报警规则名称'
          }
        ]
      }
    };
  },
  methods: {
    search() {
      this.$emit('search');
    },
    showAdd() {
      this.$refs.addComponent.showDialog();
    }
  }
};
</script>

<style>
</style>
